# $Id: PKGBUILD 80770 2012-12-03 14:13:31Z spupykin $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Peter Simons <simons@cryp.to>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=rfc
pkgver=20121203
pkgrel=1
pkgdesc="RFCs from rfc-editor.org"
arch=('any')
url="http://www.rfc-editor.org/"
license=("custom:as-is")
options=('docs')
source=(rfc-index-$pkgver.txt::http://www.rfc-editor.org/rfc/rfc-index.txt
        license
        http://www.rfc-editor.org/rfc/tar/RFCs0001-0500.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs0501-1000.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs1001-1500.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs1501-2000.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs2001-2500.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs2501-3000.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs3001-3500.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs3501-4000.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs4001-4500.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs4501-5000.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs5001-5500.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs5501-6000.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs6001-6500.tar.gz
        http://www.rfc-editor.org/rfc/tar/RFCs6501-latest.tar.gz)
md5sums=('d74eff5d6852b195c29ac14a80d71ac2'
         '06a779406b45edddbd19fda96696ab4a'
         'c33a39f99094a3f708c94c4829dceadc'
         '8ba023695d6f21253a7050ad4d638024'
         '4e3f5d1ec7e207a92c259afe4e68d8f9'
         'ca77a49134cd2b4a3528da0a01f55500'
         '063af3bde80602264bcffd6ff30b3427'
         '80de1d7fbfec6b992f0a7ca999adb29c'
         'b40f17e162a8dce51e3643c0b457bc28'
         '907318d7032e6c6e36c4973e9da59a1d'
         'df056ace2105109c3f9a2f5171cee963'
         'b7af4fb9a7d6e90434aa990d3458e12e'
         'cb59086e8d3cd5a2d11ad4a06aa3a44d'
         'd86c7ad6e3f02626f9e4c48ea73b30f3'
         '4284e20f72c66e04845e8898e87791d3'
         '9ee11e16c557c133bf850b5f472d1e91')

build() {
    cd "$srcdir"

    mkdir -p "$pkgdir/usr/share/doc/rfc"
    cp rfc-index-$pkgver.txt "$pkgdir/usr/share/doc/rfc/rfc-index.txt"
    rm -f rfc-index-$pkgver.txt

    tar xf rfc1305.tar
    rm -f rfc1305.tar
    for n in ntpv3*; do
      mv "$n" "rfc1305-$n"
    done

    for fmt in txt ps pdf; do
      mkdir -p "$pkgdir/usr/share/doc/rfc/${fmt}"
      mv *.${fmt} "$pkgdir/usr/share/doc/rfc/${fmt}/"
    done

    cd "$pkgdir/usr/share/doc/rfc"
    find . -type f -exec chmod 444 {} \;
    find . -type d -exec chmod 555 {} \;
    chown -R root:root .
    install -D -m0644 $srcdir/license $pkgdir/usr/share/licenses/$pkgname/license
}
